<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body {
            padding: 0;
            margin: 0;
        }
        a {
           text-decoration: none;
           color: #000;
        }
        .login-header {
            height: 30px;
            font-size: 24px;
            line-height: 30px;
            text-align: center;
           
        }
        .bgm {
            display: none;
            position: fixed;
            width: 100%;
            height: 100%;
            left: 0;
            top: 0;
            background: rgba(0, 0, 0, .3);

        }
        input {
            outline: none;
           
        }
        .login-header a{
            color: #000;
        }
        .login {
            display: none;
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translateX(-50%) translateY(-50%);
            width: 512px;
            height: 280px;
            background-color: #fff;
            border: #ebebeb solid 1px;
            box-shadow: 0px 0px 20px #ddd;
            z-index: 999;

        }
        .login-title {
            height: 40px;
            line-height: 40px;
            text-align: center;
            font-size: 18px;
            position: relative;
            cursor: move;
        }
        .login-title span{
             position: absolute;
             width: 40px;
             height: 40px;
             right: -16px;
             top: -18px;
             border-radius: 20px;
             background-color: #fff;
             font-size: 12px;
        }
        .login-input-content {
            margin-top: 20px;
        }
        .login-input {
            overflow: hidden;
            margin-bottom: 20px;
        }
        .login-input input {
            float: left;
            width: 350px;
            height: 35px;
            border: 1px solid #ccc;
        }
        .login-input label {
            float: left;
            width: 90px;
            height: 35px;
            line-height: 35px;
            text-align: right;
        }
    </style>
</head>
<body>
    <div class="login-header">
        <a href="#" id="link">召唤神龙</a>
    </div>
    <div class="login">
        <div class="login-title" id="title">
             神龙登录
             <span><a id="closeBtn" href="javascript:void(0);" class="close-login">关闭</a></span>
        </div>
        <div class="login-input-content">
            <div class="login-input">
                <label for="t1">用户名：</label>
                <input type="text" placeholder="请输入用户名" id="t1">
            </div>
            <div class="login-input">
                <label for="t2">密码：</label>
                <input type="password" placeholder="请输入密码" id="t2">
            </div>
        </div>
    </div>
    <div class="bgm"></div>
    <script>
       var link = document.querySelector('#link')
       var bgm = document.querySelector('.bgm')
       var login = document.querySelector('.login')
       var title = document.querySelector('#title')
       link.addEventListener('click',function(){
           bgm.style.display = 'block'
           login.style.display = 'block'
       })
    //    console.log(title.children[0].children[0]);
    title.children[0].children[0].addEventListener('click',function(){
        bgm.style.display = 'none'
           login.style.display = 'none'
    })
       title.addEventListener('mousedown',function(e){
           var x  = e.pageX - login.offsetLeft;
           var y = e.pageY - login.offsetTop;
           document.addEventListener('mousemove',move)
           function move(e){
                 login.style.top =e.pageY - y+'px'
                 login.style.left =e.pageX- x+'px'

           }
           document.addEventListener('mouseup',function(){
               document.removeEventListener('mousemove',move)
           })
       })
      
    </script>
</body>
</html>